<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">  
<html>
  <head>
  <base target="_self"/>
  
  <title>表单基本信息添加页面</title>
  	<meta http-equiv="X-UA-Compatible" content="IE=7" />
    <link rel="stylesheet" type="text/css" href="<%=path %>/web/style/layout.css" />
     <script type="text/javascript" src="<%=path %>/jqGrid/js/jquery-1.7.2.min.js"></script>
    <script type="text/javascript" src="<%=path %>/jslib/jquery.validate.min.js"></script>
    <script type='text/javascript' src="<%=request.getContextPath() %>/jslib/My97DatePicker/WdatePicker.js" defer="defer"></script>
    <script type='text/javascript' src="<%=request.getContextPath() %>/jslib/jquery.form.js"></script>
    <script type="text/javascript" src="<%=request.getContextPath() %>/jslib/additional-methods.js"></script>
    <link rel="stylesheet" type="text/css" href="<%=request.getContextPath() %>/jslib/jquery-easyui-1.4.1/themes/default/easyui.css">
	<link rel="stylesheet" type="text/css" href="<%=request.getContextPath() %>/jslib/jquery-easyui-1.4.1/themes/icon.css">
	<link rel="stylesheet" type="text/css" href="<%=request.getContextPath() %>/jslib/jquery-easyui-1.4.1/demo.css">
	<script type="text/javascript" src="<%=request.getContextPath() %>/jslib/jquery-easyui-1.4.1/jquery.easyui.min.js"></script>
    <c:if test="${requestScope.message!=null}">
		<script type="text/javascript">
 	 		     alert('<c:out value="${requestScope.message}"></c:out>');
 	 		     window.close();
 		</script>
	</c:if>
    <script type="text/javascript">
    var api = frameElement.api, W = api.opener;
    $().ready(function() {
    	// 准备好Options对象
    	var options = {
    	    url:'<%=request.getContextPath() %>/pipePointAction!saveAutoSearch.action',
    	    beforeSubmit:checkForm,
    	    dataType:'json',
    	    success: function(data) {
    	      if(data.result=='success'){
				alert("添加成功");
				api.close();
				W.refreshIt();
    	      }else if(data.result=='errorExist'){
    	      	alert("表已存在，请修改表单英文名称！");
    	      	$("#formEnName").focus();
    	      }else{
    	      	alert("系统繁忙，请您稍后再试！");
    	      	api.close();
				W.refreshIt();
    	      }
    	}};
    	
		$('#saveBtn').click(function(){
			$('#pageFrom').ajaxSubmit(options);
			return false;
		});
		
		$('#closeBtn').click(function(){
			api.close();
		});
	});
//表单验证
    function checkForm()
    {
      var formCnName = $.trim($("#formCnName").val());
      var formEnName = $.trim($("#formEnName").val()); 
      var myPattern = new RegExp("^[a-zA-Z]");
      
      if(formCnName==''){
      		alert("表单中文名称不能为空!");
			$("#formCnName").focus();
			return false;
      }else if(!checkExp(formCnName)){
			alert("表单中文名称不能含有除_以外的特殊符号!");
			$("#formCnName").focus();
			return false;
	  } 
	  
	  if(formEnName==''){
	  	     alert("表单英文名称不能为空!");
			 $("#formEnName").focus();
			 return false;
	  }else{
	        if(!myPattern.exec(formEnName)) {
	   	       alert("表单英文名称必须以字母开头!");
	   	       $("#formEnName").focus();
	   	       return false;
	   	    }
	   	    if(!checkExp(formEnName)){
				alert("表单英文名称不能含有除_以外的特殊符号!");
				$("#fieldName").focus();
				return false;
			} 			
	  }    
     }
   //验证特殊字符
	function checkExp(inputData){ 
		var regEx = new RegExp(/^(([^\^\.<>%&',:;=?$"'#@!~\]\[{}【】￥（）！·‘’”“。，、？：；—|\/\\/`\|])*)$/);
		var result = inputData.match(regEx);
		if (result == null) {
		return false;
		}
		return true;
	} 
	function countlen(textarea){
	    if (textarea.value.length> 250){
	        alert("最多为250个字符,字符输入超出限制!");
	        textarea.value=textarea.value.substring(0,250);
	    }
	    return true;
	}
	function specialType1(){
		if(document.getElementById("specialColumn").value!=''&&document.getElementById("specialColumn").value!=2){
		
			document.getElementById("r1").style.display="";
			document.getElementById("r2").style.display="";
		}else{
			document.getElementById("r1").style.display="none";
			document.getElementById("r2").style.display="none";
		}
	}
	
</script>

 <style type="text/css">
	body{
		background:#ffffff; background-image:url(images/);
	}
</style>
</head>
<body>
  	<form action="" id="pageFrom" name="" method="post">
  		<table width="100%" border="0" align="center" cellpadding="5" cellspacing="5" class="formTableNew">
		  <tr>
		    <td align="right" width="20%">查询中文名称：</td>
		    <td align="left">
				<input type="text" id="formCnName" name="formCnName" value="" style="border: 1px solid #999;padding: 5px;width: 200px;" maxlength="40"/>
				<img src="<%=request.getContextPath() %>/images/xh.png"></img>
		    </td>
		  </tr>
		  <tr> 
		    <td align="right" width="20%">查询英文名称：</td>
		    <td align="left">
				<input type="text" id="formEnName" name="formEnName" value="" maxlength="20" style="border: 1px solid #999;padding: 5px;width: 200px;" maxlength="40"/>
				<img src="<%=request.getContextPath() %>/images/xh.png"></img>
		    </td>
		  </tr>
		  <tr>
		    <td align="center" colspan="4" >
		    	<input type="button" id="saveBtn" value="提 交" class="form_bt_orange" />
		      	<input type="button" id="closeBtn" value="取 消" class="form_bt_grey" />
		    </td>
		  </tr>
		</table>
		<input type="hidden" id="formType" name="formType" value="<%=request.getParameter("fromtype") %>" />
	</form>
  </body>
</html>